//类实现继承过程
//引入模块
const events = require("events");
const EventEmitter = events.EventEmitter;

//类
class Dog extends EventEmitter {
    //构造函数
    constructor(dogName, energy) {
        super();
        this.dogName = dogName;
        this.energy = energy;
    }
}

let dog = new Dog("taidy", 5);
dog.on("bark", () => {
    console.log("dog is barking");
})
dog.emit("bark");